# -*- coding: utf-8 -*-
# Author: xiantingDeng
# File: conftest.py
# Time: 17:07
import pytest
from appium import webdriver
from .base_driver import BaseDriver


# import pytest

def pytest_addoption(parser):
    # parser.addoption("--myopt", action="store_true", help="some boolean option")
    # parser.addoption("--foo", action="store", default="bar", help="foo: bar or baz")
    parser.addoption("--cmdopt", action="store", default="device_info", help=None)


# @pytest.fixture()
# def foo(pytestconfig):
#     return pytestconfig.option.foo


# @pytest.fixture()
# def myopt(pytestconfig):
#     return pytestconfig.option.myopt


driver = None


# def pytest_addoption(parser):
#     parser.addoption("--cmdopt", action="store", default="device_info", help=None)


@pytest.fixture(scope="session")
def cmdopt(pytestconfig):
    # 两种写法
    return pytestconfig.getoption("--cmdopt")
    # return pytestconfig.option.cmdopt


# 定义公共的fixture
@pytest.fixture(scope="session")
def common_driver(cmdopt):
    global driver
    base_driver = BaseDriver(eval(cmdopt))
    driver = base_driver.base_driver()
    yield driver
    # driver.close_app()
    # driver.quit()
